Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPES-1549: Allow to delete users #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AaronGilMartinez
Copy link
Contributor

Fixes #184

@AaronGilMartinez AaronGilMartinez force-pushed the disable-delete-user branch 3 times, most recently from 4b81d7f to 3b80ff9 Compare February 11, 2025 08:41
@AaronGilMartinez AaronGilMartinez marked this pull request as ready for review February 11, 2025 08:43
config/schema/oe_authentication.schema.yml Outdated Show resolved Hide resolved
oe_authentication.permissions.yml Outdated Show resolved Hide resolved
oe_authentication.permissions.yml Outdated Show resolved Hide resolved
oe_authentication.permissions.yml Outdated Show resolved Hide resolved
oe_authentication.post_update.php Show resolved Hide resolved
src/Form/AuthenticationSettingsForm.php Outdated Show resolved Hide resolved
src/Form/AuthenticationSettingsForm.php Show resolved Hide resolved
oe_authentication.module Show resolved Hide resolved
Copy link

@donquixote donquixote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of feedback.
I want to submit this already, but I still want to have a closer look at the new tests.

@AaronGilMartinez AaronGilMartinez force-pushed the disable-delete-user branch 5 times, most recently from b671bea to 6a3a844 Compare February 18, 2025 11:58
Copy link

@donquixote donquixote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes suggested, but not hard blockers.

config/install/oe_authentication.settings.yml Show resolved Hide resolved
config/schema/oe_authentication.schema.yml Show resolved Hide resolved
oe_authentication.module Show resolved Hide resolved
oe_authentication.post_update.php Show resolved Hide resolved
src/Form/AuthenticationSettingsForm.php Show resolved Hide resolved
tests/Behat/AuthenticationContext.php Outdated Show resolved Hide resolved
tests/features/user-management.feature Show resolved Hide resolved
tests/Behat/AuthenticationContext.php Outdated Show resolved Hide resolved
oe_authentication.module Outdated Show resolved Hide resolved
@donquixote
Copy link

donquixote commented Feb 18, 2025

Some points we missed in our latest planning.

Conflict with default method

If we enable "Restrict options" setting, but set the default cancel method to something that deletes, then:

  • Users with option to choose a cancel method can only choose the remaining methods.
  • Users without that option, but permission to cancel their own account, can permanently delete their own account.

Interesting find in AccountSettingsForm:

    $form['registration_cancellation']['user_cancel_method'] += user_cancel_methods();
    foreach (Element::children($form['registration_cancellation']['user_cancel_method']) as $key) {
      // All account cancellation methods that specify #access cannot be
      // configured as default method.
      // @see hook_user_cancel_methods_alter()
      if (isset($form['registration_cancellation']['user_cancel_method'][$key]['#access'])) {
        $form['registration_cancellation']['user_cancel_method'][$key]['#access'] = FALSE;
      }
    }

See the comment about 'access' key.
This means that fixing the @todo about 'access' would actually fix one half of this dilemma.

Right now / with this PR, the available options in the account settings form are dependent on your user account, that is, whether you are uid 1.

I think this entire problem is not a regression, so we could move ahead and ignore it for now.

Which form to use

From UX perspective it seems this setting belongs into "Account settings" form, not "Authentication settings".
Only from the module developer perspective it would make sense to put it in "Authentication settings" because the functionality is provided by oe_authentication module.

TBD with rest of the team.

@brummbar
Copy link
Contributor

As per #79 (comment), it's for the site developers to configure a proper default method when restricting the options. Since the module behaves already in that way, we won't add anything as part of this pull request. We could iterate in a different one.

oe_authentication.module Outdated Show resolved Hide resolved
$current_user = \Drupal::currentUser();
$restrict_user_delete = \Drupal::configFactory()
->get('oe_authentication.settings')
->get('restrict_user_delete_cancel_methods');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to add a fallback to TRUE, just for the sake of it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we don't, and rely on upgrade path?
I don't mind if we add it..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know we went back and forth a lot on this. I first said no, then I said ok to add it just to avoid any disruption.

And I should see "Delete the account and make its content belong to the Anonymous user."

Scenario: Users should be able to delete other users when the configuration to
restrict the user delete options is not enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't split this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete user
3 participants